package com.eastfair.security.apiconditioncore;

import org.springframework.util.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ConditionUtil {
    /**
     * 解析版本号为数字
     *
     * @param versionValue
     * @return
     */
    public static int parseVersion(String versionValue) {
        String regEx = "[^0-9]";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(versionValue);
        String numStr = m.replaceAll("").trim();
        if (!StringUtils.isEmpty(numStr)) {
            return Integer.parseInt(numStr);
        }
        return 0;
    }
}
